/**
 * author:Administrator
 * date:2016/1/4
 * desc:TODO
 */

'use strict';
var app = require('koa')();

//---logger
app.use(function*(next) {
  var start = new Date();
  yield next;
  var ms = new Date() - start;
  console.log('%s %s - %s', this.method, this.url, ms);
});

app.use(require('./router/params_collector.js'));
app.use(require('./router/reset.js'));
app.use(require('./router/coupon.js'));
app.use(require('./router/order.js'));


// 404
app.use(function*() {
  this.status = 404;
  this.body = '~~~404 not found~~~';
});


app.listen(9990, function () {
  console.log('server listen at localhost:%s', 9990);
});